package com.foreveross.vo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.foreveross.util.NotSerialize;
import com.foreveross.vo.common.AffiliatedBaseVo;

/**
 * 楼盘信息表 HrHouses entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "hr_houses", catalog = "hrtenement")
public class HrHouses extends AffiliatedBaseVo implements java.io.Serializable {

	// Fields

	private String id;
	private String projectId;
	private String name;
	private String address;
	private String url;
	private HrCode province;
	private String provinceId;
	private String city;
	private ProductType proType;
	private ProductType proLine;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date finishTime;
	private String isShow;

	private String proTypeId;
	private String proLineId;

	private String proTypeName;

	private String provinceName;
	
	private Object other;
	
	@NotSerialize
	private List<MessageHouse> messageHouses = new ArrayList<MessageHouse>();

	@NotSerialize
	private List<NewsHouse> newsHouses = new ArrayList<NewsHouse>();

	@NotSerialize
	private List<OptimizedHouse> optimizedHouses = new ArrayList<OptimizedHouse>();
	// Constructors

	/** default constructor */
	public HrHouses() {
	}

	/** minimal constructor */
	public HrHouses(String id) {
		this.id = id;
	}

	/** full constructor */
	public HrHouses(String id, String projectId, String name, String address,
			String content, String url, HrCode province, String city,
			ProductType proType, ProductType proLine, Date finishTime,
			String isShow) {
		this.id = id;
		this.projectId = projectId;
		this.name = name;
		this.address = address;
		this.url = url;
		this.province = province;
		this.city = city;
		this.proType = proType;
		this.proLine = proLine;
		this.finishTime = finishTime;
		this.isShow = isShow;
	}

	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "project_id")
	public String getProjectId() {
		return this.projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "url")
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "province")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrCode getProvince() {
		return this.province;
	}

	public void setProvince(HrCode province) {
		this.province = province;
	}

	@Column(name = "city")
	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "pro_type")
	@NotFound(action=NotFoundAction.IGNORE)
	public ProductType getProType() {
		return this.proType;
	}

	public void setProType(ProductType proType) {
		this.proType = proType;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "pro_line")
	@NotFound(action=NotFoundAction.IGNORE)
	public ProductType getProLine() {
		return this.proLine;
	}

	public void setProLine(ProductType proLine) {
		this.proLine = proLine;
	}

	@Column(name = "finish_time")
	public Date getFinishTime() {
		return this.finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}

	@Column(name = "is_show")
	public String getIsShow() {
		return this.isShow;
	}

	public void setIsShow(String isShow) {
		this.isShow = isShow;
	}

	@Transient
	public String getProTypeId() {
		if (proType != null)
			return proType.getId();
		return proTypeId;
	}

	public void setProTypeId(String proTypeId) {
		this.proTypeId = proTypeId;
	}

	@Transient
	public String getProLineId() {
		if (proLine != null)
			return proLine.getId();
		return proLineId;
	}

	public void setProLineId(String proLineId) {
		this.proLineId = proLineId;
	}

	@Transient
	public String getProTypeName() {
		if (proType != null)
			return proType.getProName();
		return proTypeName;
	}

	public void setProTypeName(String proTypeName) {
		this.proTypeName = proTypeName;
	}

	@Transient
	public String getProvinceName() {
		if (province != null)
			return province.getCodeDesc();
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	
	@Transient
	public String getProvinceId() {
		if (province != null)
			return province.getCodeId();
		return provinceId;
	}

	public void setProvinceId(String provinceId) {
		this.provinceId = provinceId;
	}	
	
	@Transient
	public Object getOther() {
		return other;
	}

	public void setOther(Object other) {
		this.other = other;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "house")
	public List<MessageHouse> getMessageHouses() {
		return messageHouses;
	}

	public void setMessageHouses(List<MessageHouse> messageHouses) {
		this.messageHouses = messageHouses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "house")
	public List<NewsHouse> getNewsHouses() {
		return this.newsHouses;
	}

	public void setNewsHouses(List<NewsHouse> newsHouses) {
		this.newsHouses = newsHouses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "house")
	public List<OptimizedHouse> getOptimizedHouses() {
		return optimizedHouses;
	}

	public void setOptimizedHouses(List<OptimizedHouse> optimizedHouses) {
		this.optimizedHouses = optimizedHouses;
	}
	
	
}